Official website: http://snapkit.io/Github:https://github.com/snapkit/snapkitSnapkit is a DSL-to-make Auto-Layout easy on both IOS and OS x.
Simple Expressive Chaining DSL allows building constraints with minimal amounts of code while ensuring they is easy To read and understand.
Type Safe by design to reduce programmer error and keep invalid constraints from being created on the first place for Maxi mized productivity.
Compatible fo
Adapted to a variety of screen sizes, IOS 6 introduced the concept of automatic layout (auto Layout), through the use of various Constraint (constraints) to achieve a page adaptive elastic layout. (For more information, see my original article: Swift-use auto layout and size classes to achieve a resilient page layout)
It is convenient to use constraints in StoryBoard to automate layout, but it is cumbersome to set constraints with pure code. Here to recommend a useful Third-party layout li
During OC development I used a third-party AutoLayout library called Masonry, and after turning to Swift found that although Swift can be mixed OC, but always feel a bit of trouble, found on GitHub, this is called Snapkit third-party library, found to use more convenient, Share with you1. Download Snapkit on GitHub, choose iOS target Compilation (command+b), find Snapkit.framework2. Right button "Show in Fi
During OC development I used a third-party AutoLayout library called Masonry, and after turning to Swift found that although Swift can be mixed OC, but always feel a bit of trouble, found on GitHub, this is called Snapkit third-party library, found to use more convenient, Share with you1. Download Snapkit on GitHub, choose iOS target Compilation (command+b), find Snapkit.framework2. Right button "Show in Fi
I've used masonary before, and now I want to use the Swift version SnapkitGit link: https://github.com/SnapKit/SnapKit.git.The download will not run, there are some errors.My Xcode version is 7.2 and should be enough.The things I do:1, downloaded the project, compiled but2, reference http://www.hangge.com/blog/cache/detail_1097.html. The idea is to import the entire project into Snapkit and then add the
Snapkit:
Https://github.com/SnapKit/SnapKit
v.snp_makeconstraints {(make) in
Because Swift is not the same as OC Syntax Equalto (self.view) is an incoming parameter
Make.top.equalTo (Self.view). Offset (100)
Make.left.equalTo (Self.view). Offset (100)
Make.right.equalTo (Self.view). Offset (-100)
Make.bottom.equalTo (Self.view). Offset (-100)
}
Masonry:
Https
In the previous article I introduced how to use the Snapkit Snp_makeconstraints method to set various constraints. But sometimes our pages are not always fixed, which requires modifying existing constraints. This article describes how to update, remove, and replace existing constraints.
1, delete the constraint
To update or remove an existing constraint, we need to assign the result of the constraint to a local variable or a class property, and then
The previous articles explain how to use automatic layout library Snapkit. This article uses a complete sample (login page) to demonstrate how to automate the layout using Snapkit in the actual project.
1, the effect chart is as follows
2, Code explanation(1) User name, password input area (white area) Set Vertical center constraint, its height is fixed 90, width adaptive (15 pixels from the left and ri
How do I implement keyboard following when using Snapkit layout?In the previous article, our page used the Constraints constraint layout. If the page element is to use Snapkit this third party layout library to layout, also can realize keyboard follow up move effect.The implementation is also to monitor the keyboard notification, and then change the constraints, so as to achieve the move animation effect.
Snapkit:
v.snp_makeconstraints {(make) in
Because Swift and OC syntax are not the same equalto (Self.view) is an incoming parameter
Make.top.equalTo (Self.view). Offset (100)
Make.left.equalTo (Self.view). Offset (100)
Make.right.equalTo (Self.view). Offset (-100)
Make.bottom.equalTo (Self.view). Offset (-100)
}
Masonry:
Because Swift and OC syntax are not the same equalto () is called first by the Get method
v.mas_makeconstraints {(make) in
Make.t
1, constraint precedence
When we use Snapkit, we can also define the precedence of the constraint. In this way, when the constraint is conflicting, the precedence constraint overrides the lower precedence constraint. The specific priority can be placed at the end of the constraint chain.
(1) You can set the following several priority levels
Prioritylow (): Set low priority, priority is 250Prioritymedium (): Set in priority, priority is 500 (this is
important, The main conclusion is that at the outset of the layout, it is necessary to consider different scenarios to accommodate different layout requirements.Now that the code layout is started, and the code layout uses a third-party class library to save code, Apple's API is very cumbersome, using Snapkit as the Layout class library (https://github.com/SnapKit/Snap
program is activated and can query the map)
2. When querying a map, I still need to use my APP. At this time, my APP is activated and the map is also activated)
3. I want to zoom in the Map Program. The map is cut into half a display by SplitView. (5: 5)
As shown in the preceding figure, scenario 1: My APP exists as a slave APP, the photo is a master APP, Scenario 2: My APP exists as a master APP, and the map APP is a slave APP, in fact, this is not important. The main conclusion is that at the
Brief introductionThis article mainly reviews the --ios functional programming responsive programming concept , how to realize the process of functional programming step-by-step, to read the Masonry SnapKit source code has certain help. Image matchingAs an iOS developer, you must have used masnory/snapkit;
Masonry is a third-party framework that is well-suited for automatic layout in OC developme
follows:The Pods folder contains the downloaded third-party dependent libraries.Open the project file Demo.xcworkspace. The project structure at this point is as follows:Third, the use of Alamofire libraryWe opened the Viewcontroller.swift and introduced the Alamofir library. Add an "import Alamofire" below the import UIKit line in the header of the file , make sure you do this step, or you will not use the library's API. Then the super in the viewdidload () method . Viewdidload() The foll
when swift loading suddenly increases to 400ms. This is because the dynamic framework of the system will only load one copy. Assuming that 10 app launches are used for Uikit, only one uikit is loaded inside the system. So sometimes the swift project starts with the system framework without caching, and it looks a bit longer. 6 Framework
Now let's compare the situation with the code. Two projects were added to 5 dependencies.This is 6 dependencies of the OC Project:
Pod ' afnetworking ', ' ~>
entire view, and the bottom of the parent view aligns the imageview of the bottom two bottom either.2. Automatic adjustment according to text length in Uilabel-* *Todo3. Uitextview height with brother view how much adjustment-* * *Todo4. AutoLayout of Swift via Snapkit components-*Snapkit is a third-party AutoLayout library based on the Swift language, which simplifies the amount of code to set constraints
Masonry is a lightweight framework that iOS often uses in control layouts, and masonry makes nslayoutconstraint easier to use. Masonry simplifies the way nslayoutconstraint is used, so that we can assign constraints to our controls in a chained fashion. The topic of this blog is not to teach you how to use the masonry framework, but the masonry framework to parse the source code, let you understand how masonry nslayoutconstraint encapsulation, And the role of the various parts of the masonry fr
Masonry is a lightweight framework that iOS often uses in control layouts, and masonry makes nslayoutconstraint easier to use. Masonry simplifies the way nslayoutconstraint is used, so that we can assign constraints to our controls in a chained fashion. The topic of this blog is not to teach you how to use the masonry framework, but the masonry framework to parse the source code, let you understand how masonry nslayoutconstraint encapsulation, And the role of the various parts of the masonry fra
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.